<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>静态变量</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <div style="text-align:left" class="jtbl">
        <el-row :gutter="10" v-for="item in list" :key="item.i">
          <hr />
          <el-col :span="7">
            <span class="spanFont">{{ item.remark }}:</span></el-col
          >
          <el-col :span="6">
            <el-input
              v-model="item.value"
              :name="item.type"
              placeholder="请输入内容"
              ref="name"
            >
            </el-input>
          </el-col>
        </el-row>
        <!-- <el-row :gutter="20">
          <el-col :span="2" class="spanFont">全网互动量</el-col>
          <el-col :span="1" class="spanFont">{{ tibiYue }}</el-col>
          <el-col :span="3" class="spanFont">全网互动量额度添加:</el-col>
          <el-col :span="4" class="spanFont"><el-input v-model="addQwCumulationSum" type="text" placeholder="请输入内容"></el-input></el-col>
          <el-col :span="3" class="spanFont">全网互动量额度减少:</el-col>
          <el-col :span="4" class="spanFont"><el-input v-model="subQwCumulationSum" type="text" placeholder="请输入内容"></el-input></el-col>
        </el-row> -->
        <!-- <el-row :gutter="20">
          <el-col :span="2" class="spanFont">今日互动量:</el-col>
          <el-col :span="1" class="spanFont">{{ tibiYue }}</el-col>
          <el-col :span="3" class="spanFont">今日互动量额度添加:</el-col>
          <el-col :span="4" class="spanFont"><el-input v-model="addToDaySum" type="text" placeholder="请输入内容"></el-input></el-col>
          <el-col :span="3" class="spanFont">今日互动量额度减少:</el-col>
          <el-col :span="4" class="spanFont"><el-input v-model="subToDaySum" type="text" placeholder="请输入内容"></el-input></el-col>
        </el-row> -->
        <hr />
        <el-row :gutter="10">
          <el-button type="primary" size="mini" @click="submit()"
            >提交</el-button
          >
        </el-row>
      </div>
    </el-card>
    <!-- <el-dialog title="输入验证码" :visible.sync="CodeDialogVisible" width="30%">
      <el-row>
        <el-col :span="6" class="spanFont">输入验证码:</el-col>
        <el-col :span="8">
          <el-input v-model="PutCode" placeholder="请输入内容"></el-input
        ></el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit()">确定</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      qwsl: "",
      tibiYue: "",
      PutCode: "",
      CodeDialogVisible: false,
      list: [],
      addQwCumulationSum:"",
      subQwCumulationSum:"",
      addToDaySum:"",
      subToDaySum:"",
    };
  },
  created() {
    this.getmsglist();
  },
  methods: {
    //获取数据列表
    async getmsglist() {
      const { data: res } = await this.$http.post(
        "currencyAudit/getStaticData"
      );
      if (res.code !== 200) return this.$message.error("加载数据失败");
      this.list = res.data.list;
      this.tibiYue = res.data.tibi;
      this.qwsl = res.data.qwsl;
    },
    // 确认提交
    async submit() {
      var json = [];
      var lists = this.$refs.name;
      for (var i in lists) {
        var row = {};
        row.type = lists[i].$attrs.name;
        row.value = lists[i].value;
        json.push(row);
      }
      json = JSON.stringify(json); //转字符串
      let formdata = new FormData();
      formdata.append("list", json);
      // formdata.append("addQwCumulationSum", this.addQwCumulationSum);
      // formdata.append("subQwCumulationSum", this.subQwCumulationSum);
      // formdata.append("addToDaySum", this.addToDaySum);
      // formdata.append("subToDaySum", this.subToDaySum);
      const { data: res } = await this.$http.post(
        "currencyAudit/updateStaticData",
        formdata
      );
      if (res.code !== 200) return this.$message.error("提交修改失败");
      this.$message.success("提交修改成功");
      this.getmsglist();
    },
  },
};
</script>
<style lang="less" scoped>
.el-row {
  line-height: 40px;
  margin: 10px;
}
.spanFont {
  font-size: 16px;
  font-weight: 600;
}
</style>
